<?php


namespace app\api\controller;

use app\api\logic\CardLogic;
use app\api\logic\LoftLogic;
use app\api\logic\ServiceLogic;
use app\common\controller\RestController;
use app\common\models\Service\ServicesUser;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

class Loft extends RestController
{
    protected $noNeedLogin = [];

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function loftList(): bool
    {
        $page = input('page',1);
        $pageSize = input('pageSize',10);
        $info = LoftLogic::getInstance()->loftList($page,$pageSize);
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function servicesList(): bool
    {
        $page = input('page',1);
        $pageSize = input('pageSize',10);
        $cateId = input('cate_id');
        $serviceId = input('serviceId');
        $info = LoftLogic::getInstance()->servicesList($page,$pageSize,$cateId,$serviceId);
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function servicesCate(): bool
    {
        $info = LoftLogic::getInstance()->servicesCate();
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function servicesUserAdd(): bool
    {
        $ids = input('ids');
        $status = input('status');
        $serviceId = input('serviceId');
        $info = LoftLogic::getInstance()->servicesUserAdd($ids,$status,$serviceId);
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public function serviceOrderList(): bool
    {
        $page = input('page',1);
        $pageSize = input('pageSize',10);
        $serviceId = input('serviceId');
        $status = input('status');
        $orderNo = input('orderNo');
        $info = LoftLogic::getInstance()->serviceOrderList($page,$pageSize,$serviceId,$status,$orderNo);
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function serviceOrderDetail(): bool
    {
        $orderNo = input('orderNo');
        $info = ServiceLogic::getInstance()->serviceOrderDetail($orderNo);
        return $this->result($info);
    }

    public function servicesUserList(): bool
    {
        $page      = input('page', 1);
        $pageSize  = input('pageSize', 10);
        $serviceId  = input('serviceId');
        $status = input('status');
        $info = LoftLogic::getInstance()->servicesUserList($page,$pageSize,$serviceId,$status);
        return $this->result($info);
    }

    public function servicesUserStatus(): bool
    {
        $ids = input('ids');
        $status = input('status');
        $info = LoftLogic::getInstance()->servicesUserStatus($ids,$status);
        return $this->result($info);
    }

    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function check(): bool
    {
        $orderNo = input('orderNo');
        $serviceId  = input('serviceId');
        $info = LoftLogic::getInstance()->check($orderNo,$serviceId);
        return $this->result($info);
    }

    public function info(): bool
    {
        $serviceId  = input('serviceId');
        $info = LoftLogic::getInstance()->info($serviceId);
        return $this->result($info);
    }

    public function getServiceAmountLog(): bool
    {
        $startAt = input('startAt', '');
        $endAt = input('endAt', '');
        $logType = input('logType', '');
        $page = input('page', 1);
        $serviceId = input('serviceId');
        $pageSize = input('pageSize', 10);
        $info = LoftLogic::getInstance()->getServiceAmountLog($startAt, $endAt, $logType, $page, $pageSize,$serviceId);
        return $this->result($info);
    }


}